package com.systech.core.util.xml;

import java.io.StringWriter;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Document;

public class XMLUtils {

	/**
	 * Convierte un Documento xml en un string
	 * @param doc
	 * @return
	 * @throws Exception
	 */
	public static String documentToString(Document doc)throws Exception{ 
        TransformerFactory tFactory = TransformerFactory.newInstance(); 
        Transformer transformer = tFactory.newTransformer(); 
        DOMSource source = new DOMSource(doc); 
        StringWriter sw=new StringWriter(); 
        StreamResult result = new StreamResult(sw); 
        transformer.transform(source, result); 
        String xmlString=sw.toString(); 
        return xmlString; 
         
    }  
	
}
